home *** CD-ROM | disk | FTP | other *** search
/ Beginning Mac Programming / Beginning Mac Programming.bin / Open Me for REALbasic 3 / REALbasic 3.2 / Example Projects / Techniques / Examples by Joe Strout / Basic Console / Sample Programs.txt < prev   
Text File  |  2000-04-17  |  1KB  |  64 lines

  1. Sample Console-Basic Programs
  2.  
  3. This file contains some sample programs for use with the Console app.  Copy
  4. the contents of "ProgramCode" into the Main() method of the ProgramCode class
  5. in RB.  Copy the contents of "ProgramData" (if any) into the Text property of
  6. the big text box in the ProgramData class in RB.  Then Run and enjoy!
  7.  
  8.  
  9. ======================================================================
  10. ProgramCode:
  11.  
  12. // This program asks your name, then prints it a number of times.
  13. Dim i as Integer
  14. Dim qtystr as String
  15. Dim name as String
  16. Dim s as String
  17. Dim done as Boolean
  18.  
  19. do until done
  20. Clear
  21. Input "Enter your name: ", name
  22. Input "Enter quantity: ", qtystr
  23.  
  24. for i = 1 to Val(qtystr)
  25. Print name + " was here!"
  26. next
  27.  
  28. Input "Do it again (Y/N)? ", s
  29. done = (left(s,1) = "N")
  30. loop
  31. ----------------------------------------------------------------------
  32. ProgramData:
  33. (none)
  34. ----------------------------------------------------------------------
  35.  
  36.  
  37.  
  38.  
  39. ======================================================================
  40. ProgramCode:
  41.  
  42. // Demonstrates use of the Read statement to grab
  43. // data from ProgramData.
  44. Dim i as integer
  45. Dim s as String
  46. Dim d as Double
  47.  
  48. for i = 1 to 3
  49. ReadStr s
  50. Print "String... >" + s + "<"
  51. next
  52.  
  53. for i = 1 to 3
  54. ReadNum d
  55. PrintNoCR "Number... "
  56. Print d
  57. next
  58. ----------------------------------------------------------------------
  59. ProgramData:
  60. "foo","bar"
  61. "baz", 1
  62. 2.5,3.8
  63. ======================================================================
  64.